﻿var status = 0;
var choice;
var scrolls = Array(
Array("", 1122138, 0),
Array("", 1122139, 0),
Array("", 1122140, 0),
Array("", 1122141, 0),
Array("", 1122142, 0),
Array("", 1122143, 0),
Array("", 1122144, 0),
Array("", 1122145, 0),
Array("", 1122146, 0),
Array("", 1122147, 0),
Array("", 1122148, 0),
Array("", 1122149, 0),
Array("", 1122150, 0),
Array("", 1122152, 0),
Array("", 1122153, 0),
Array("", 1122154, 0),
Array("", 1122155, 0),
Array("", 1122156, 0),
Array("", 1122157, 0),
Array("", 1122161, 0),
Array("", 1122162, 0),
Array("", 1122174, 0),
Array("", 1122183, 0),
Array("", 1122184, 0),
Array("", 1122185, 0),
Array("", 1122187, 0),
Array("", 1122188, 0),
Array("", 1122189, 0),
Array("", 1122194, 0),
Array("", 1122196, 0),
Array("", 1122197, 0),
Array("", 1122199, 0),
Array("", 1122200, 0),
Array("", 1122201, 0),
Array("", 1122202, 0),
Array("", 1122203, 0),
Array("", 1122205, 0),
Array("", 1122206, 0),
Array("", 1122208, 0),
Array("", 1122209, 0),
Array("", 1122214, 0),
Array("", 1122216, 0),
Array("", 1122217, 0),
Array("", 1122218, 0),
Array("", 1132000, 0),
Array("", 1132001, 0),
Array("", 1132002, 0),
Array("", 1132003, 0),
Array("", 1132004, 0),
Array("", 1132005, 0),
Array("", 1132006, 0),
Array("", 1132007, 0),
Array("", 1132008, 0),
Array("", 1132009, 0),
Array("", 1132010, 0),
Array("", 1132011, 0),
Array("", 1132012, 0),
Array("", 1132013, 0),
Array("", 1132017, 0),
Array("", 1132018, 0),
Array("", 1132019, 0),
Array("", 1132021, 0),
Array("", 1132036, 0),
Array("", 1132037, 0),
Array("", 1132038, 0),
Array("", 1132039, 0),
Array("", 1132040, 0),
Array("", 1132041, 0),
Array("", 1132043, 0),
Array("", 1132044, 0),
Array("", 1132045, 0),
Array("", 1132046, 0),
Array("", 1132047, 0),
Array("", 1132048, 0),
Array("", 1132049, 0),
Array("", 1132050, 0),
Array("", 1132051, 0),
Array("", 1132052, 0),
Array("", 1132053, 0),
Array("", 1132054, 0),
Array("", 1132055, 0),
Array("", 1132056, 0),
Array("", 1132057, 0),
Array("", 1132058, 0),
Array("", 1132059, 0),
Array("", 1132060, 0),
Array("", 1132061, 0),
Array("", 1132062, 0),
Array("", 1132063, 0),
Array("", 1132064, 0),
Array("", 1132065, 0),
Array("", 1132066, 0),
Array("", 1132067, 0),
Array("", 1132068, 0),
Array("", 1132069, 0),
Array("", 1132070, 0),
Array("", 1132071, 0),
Array("", 1132072, 0),
Array("", 1132073, 0),
Array("", 1132074, 0),
Array("", 1132075, 0),
Array("", 1132076, 0),
Array("", 1132077, 0),
Array("", 1132078, 0),
Array("", 1132079, 0),
Array("", 1132080, 0),
Array("", 1132081, 0),
Array("", 1132082, 0),
Array("", 1132083, 0),
Array("", 1132084, 0),
Array("", 1132085, 0),
Array("", 1132086, 0),
Array("", 1132087, 0),
Array("", 1132088, 0),
Array("", 1132089, 0),
Array("", 1132090, 0),
Array("", 1132091, 0),
Array("", 1132092, 0),
Array("", 1132093, 0),
Array("", 1132094, 0),
Array("", 1132095, 0),
Array("", 1132096, 0),
Array("", 1132097, 0),
Array("", 1132098, 0),
Array("", 1132102, 0),
Array("", 1132103, 0),
Array("", 1132104, 0),
Array("", 1132105, 0),
Array("", 1132106, 0),
Array("", 1132107, 0),
Array("", 1132108, 0),
Array("", 1132109, 0),
Array("", 1132110, 0),
Array("", 1132111, 0),
Array("", 1132112, 0),
Array("", 1132113, 0),
Array("", 1132114, 0),
Array("", 1132115, 0),
Array("", 1132127, 0),
Array("", 1132128, 0),
Array("", 1132133, 0),
Array("", 1132134, 0),
Array("", 1132135, 0),
Array("", 1132136, 0),
Array("", 1132138, 0),
Array("", 1132139, 0),
Array("", 1132140, 0),
Array("", 1132141, 0),
Array("", 1132142, 0),
Array("", 1132143, 0),
Array("", 1132145, 0),
Array("", 1132151, 0),
Array("", 1132152, 0),
Array("", 1132154, 0),
Array("", 1132161, 0),
Array("", 1132162, 0),
Array("", 1132164, 0),
Array("", 1132165, 0),
Array("", 1132166, 0),
Array("", 1132167, 0),
Array("", 1132168, 0),
Array("", 1132169, 0),
Array("", 1132170, 0),
Array("", 1132171, 0),
Array("", 1132172, 0),
Array("", 1132173, 0),
Array("", 1132179, 0),
Array("", 1132180, 0),
Array("", 1132181, 0),
Array("", 1132182, 0),
Array("", 1132187, 0),
Array("", 1132188, 0),
Array("", 1132189, 0),
Array("", 1132190, 0),
Array("", 1140000, 0),
Array("", 1140001, 0),
Array("", 1140002, 0),
Array("", 1141000, 0),
Array("", 1141001, 0),
Array("", 1141002, 0),
Array("", 1142000, 0),
Array("", 1142001, 0),
Array("", 1142002, 0),
Array("", 1142003, 0),
Array("", 1142004, 0),
Array("", 1142005, 0),
Array("", 1142006, 0),
Array("", 1142007, 0),
Array("", 1142008, 0),
Array("", 1142009, 0),
Array("", 1142010, 0),
Array("", 1142011, 0),
Array("", 1142012, 0),
Array("", 1142013, 0),
Array("", 1142014, 0),
Array("", 1142015, 0),
Array("", 1142016, 0),
Array("", 1142017, 0),
Array("", 1142018, 0),
Array("", 1142019, 0),
Array("", 1142020, 0),
Array("", 1142021, 0),
Array("", 1142022, 0),
Array("", 1142023, 0),
Array("", 1142024, 0),
Array("", 1142025, 0),
Array("", 1142026, 0),
Array("", 1142027, 0),
Array("", 1142028, 0),
Array("", 1142029, 0),
Array("", 1142030, 0),
Array("", 1142031, 0),
Array("", 1142032, 0),
Array("", 1142033, 0),
Array("", 1142034, 0),
Array("", 1142035, 0),
Array("", 1142036, 0),
Array("", 1142037, 0),
Array("", 1142038, 0),
Array("", 1142039, 0)
);

function start() {
    status = -1;
    action(1, 0, 0);
}

function action(mode, type, selection) {
    if (mode == -1) cm.dispose();
    else {
        if (status == 0 && mode == 0) {
            cm.dispose();
            return;
        } else if (status >= 1 && mode == 0) {
            cm.sendOk("好吧，欢迎下次继续光临！.");
            cm.dispose();
            return;
        }
        if (mode == 1) status++;
        else status--;

        if (status == 0) {
            choices = "\r\n兔兔币余额：#r" + cm.getHyPay(1) + "#k个 (#r买后不支持退货哟亲#k)";
            for (var i = 0; i < scrolls.length; i++) {
                choices += "\r\n#L" + i + "##v" + scrolls[i][1] + "##z" + scrolls[i][1] + "#　#d需要#r" + scrolls[i][2] + "#d兔兔币#k#l";
            }
            cm.sendSimpleS("欢迎来到配件2店,你想买我们商店的物品么?请选择吧：." + choices,2);
        } else if (status == 1) {
            cm.sendYesNo("你确定需要购买#v" + scrolls[selection][1] + "##t" + scrolls[selection][1] + "#?");
		choice = selection;
        } else if (status == 2) {
            var money = scrolls[choice][2];
            if (cm.getHyPay(1) < money) {
                cm.sendOk("抱歉，你没足够的兔兔币！");
                cm.dispose();
            } else {
                cm.addHyPay(money);
                cm.gainItem(scrolls[choice][1], 1);
                cm.sendOk("购买成功.");
                cm.dispose();
            }
        }
    }
}